= error_messages_for("raid")
- form_tag({ :controller => "raids", :action => :update }, { :method => :put }) do
  %table
    %tr
      %td Comment
      %td= text_field("raid", "comment", { :size => 40, :value => @raid.comment })
    %tr
      %td Date
      %td= datetime_select("raid", "date")
    %tr
      %td
      %td= submit_tag("Update")

%br

%h3 Wanted roles
- if (@raid.wanted_roles.length > 0)
  %table
    %tr
      - @raid.wanted_roles.each do |wanted_role|
        %th= wanted_role.role.name
    %tr
      - @raid.wanted_roles.each do |wanted_role|
        - still_wanted = wanted_role.count
        %td{:valign => "top"}
          %table
            - (@raid.signups.select { |s| s.accepted? }).each do |signup|
              - if signup.character.roles.include?(wanted_role.role)
                %tr{:class => "taken-spot"}
                  = render(:partial => signup.character, :locals => { :character => signup.character })
                - still_wanted = still_wanted - 1
            - (1..still_wanted).each do
              %tr{:class => "open-spot"}
                %td [unfilled]
  %br
  - form_tag(:controller => "raids", :action => :delete_wanted_role, :raid_id => @raid.id) do
    %table
      %th Role
      %th Count
      %th= submit_tag("Delete")
      - @raid.wanted_roles.each do |wanted_role|
        %tr
          %td= wanted_role.role.name
          %td= wanted_role.count
          %td= check_box_tag("deletewantedrole#{wanted_role.id}")
  %br
- form_tag(:controller => "raids", :action => :create_wanted_role, :raid_id => @raid.id) do
  = select("wanted_role", "role_id", @all_roles.collect { |r| [r.name, r.id] })
  = text_field("wanted_role", "count", { :size => 2 })
  = submit_tag("Add")

%h3 Signups
- if (@raid.signups.length > 0)
  - form_tag(:controller => "raids", :action => :update_signups, :raid_id => @raid.id) do
    %table
      %th Name
      %th Accepted
      - @raid.signups.each do |signup|
        %tr
          %td= signup.character.name
          %td= check_box("acceptsignup#{signup.id}", "accepted", :checked => signup.accepted)
      %tr
        %td
        %td= submit_tag("Update")
  %br
- unless (@signed_up_for_this_raid or @logged_in_user.character.nil?)
  - if still_got_time_to_signup_for_raid?(@raid)
    - form_tag(:controller => "raids", :action => :create_signup, :raid_id => @raid.id) do
      = submit_tag("Sign me up")
    %br
- if @signed_up_for_this_raid
  You signed up for this raid.
  %br

%h3 Rewards
= error_messages_for("reward")
- form_tag(:controller => "rewards", :action => :create, :raid_id => @raid.id) do
  %div= hidden_field("reward", "raid_id", :value => @raid.id)
  %table
    %tr
      %th Mob
      %th Comment
      %th Shares
    - @raid.rewards.each do |reward|
      %tr
        - if reward.mob
          = render(:partial => reward.mob, :locals => { :mob => reward.mob })
        - else
          %td
        %td= link_to(reward.comment, :action => :edit, :controller => "rewards", :id => reward.id)
        %td= reward.number_of_shares
    %tr
      %td= collection_select("reward", "mob_id", @raid.zone.mobs, "id", "name", :include_blank => true)
      %td= text_field("reward", "comment", { :size => 40 })
      %td= text_field("reward", "number_of_shares", { :size => 8 })
      %td= submit_tag("Add reward")

%br

%h3 Loot
= error_messages_for("loot")
- if (@raid.loot.length > 0)
  - form_tag(:controller => "raids", :action => :update_loot, :raid_id => @raid.id) do
    %div= hidden_field("loot", "raid_id", :value => @raid.id)
    %table
      %tr
        %th Winner
        %th Item
        %th Dropped by
        %th Price
        %th= submit_tag("Delete")
      - @raid.loot.each do |loot|
        %tr
          %td= select("loot#{loot.id}", "character_id", @characters.collect { |c| [c.name, c.id] }, { :selected => loot.character.id })
          %td= select("loot#{loot.id}", "item_id", @items.collect { |i| [i.name, i.id] }, { :selected => loot.item.id })
          - if loot.mob.nil?
            %td= select("loot#{loot.id}", "mob_id", @raid.zone.mobs.collect { |m| [m.name, m.id] }, { :include_blank => true })
          - else
            %td= select("loot#{loot.id}", "mob_id", @raid.zone.mobs.collect { |m| [m.name, m.id] }, { :selected => loot.mob.id, :include_blank => true })
            %td= text_field("loot#{loot.id}", "price", { :size => 8, :value => loot.price })
            %td= check_box_tag("deleteloot#{loot.id}")
      %tr
        %td
        %td
        %td
        %td= submit_tag("Update")
        %td
  %br

- form_tag(:controller => "raids", :action => :create_loot, :raid_id => @raid.id) do
  %table
    %tr
      %td= collection_select("loot", "character_id", @characters, "id", "name", { :include_blank => true })
      %td= collection_select("loot", "item_id", @items, "id", "name", { :include_blank => true })
      %td= collection_select("loot", "mob_id", @raid.zone.mobs, "id", "name", { :include_blank => true })
      %td= text_field("loot", "price", { :size => 8 })
      %td= submit_tag("Add loot")